<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增开课计划')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-plan-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">开课名称：</label>
                <div class="col-sm-8">
                    <input id="kaikeName" name="kaikeName" class="form-control" type="text" required onblur="ccc()">
                </div>
            </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">课程名称：</label>
                    <div class="col-sm-8">
                        <select th:remove="all-but-first" class="form-control" name="courseId" style="width:476px;">
                            <option th:each="list : ${list}" th:value="${list.id}" th:text="${list.courseName}"></option>
                        </select>
                    </div>
                </div>
                <!--<div class="col-sm-8">
                        <div class="input-group">
                            <input type="hidden" name="courseId" id="courseName">
                            <input class="form-control" id="suggest-demo-1" style="width:474px;"required>
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                </div>-->

<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-3 control-label">学时：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input name="stutime" id="stuTime" class="form-control" type="text" required>-->
<!--                        </div>-->
<!--                    </div>-->

<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-3 control-label">学分：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input name="stuscore" id="stuScore" class="form-control" type="text" required>-->
<!--                            </div>-->
<!--                        </div>-->

            <div class="form-group" style="display: flex;text-align: center;">
                <label class="col-sm-3 control-label">开课教师：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="courseTeacher" id="courseTeacher" th:with="teacherNames=${@user.getUserName()}" required>
                        <option value="">请选择</option>
                        <option th:each="teacherName : ${teacherNames}" th:text="${teacherName.userName}" th:value="${teacherName.loginName}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">学生类别：</label>
                <div class="col-sm-8">
                    <select name="stutype" class="form-control m-b" th:with="type=${@dict.getType('sys_stu_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">面向群体：</label>
                <div class="col-sm-8">
                    <select name="facegroup" class="form-control m-b" th:with="type=${@dict.getType('sys_profession')}">
                        <option value="0">全校</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">开课人数：</label>
                <div class="col-sm-8 d-flex" style="display: flex;align-items: center">
                    <input name="stulownumber" class="form-control" type="number" style="width:100px;" value="0" required>
                    <label>&nbsp;&nbsp;~&nbsp;&nbsp;</label>
                   <input name="stumaxnumber" class="form-control" type="number" style="width:100px;" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">学年：</label>
                <div class="col-sm-8" style="width:500px;display: flex;">
                    <select name="stuterm" class="form-control m-b" th:with="type=${@term.selectTbTermList()}">
                        <option th:each="term : ${type}" th:text="${term.schoolYear +'学年  第'+term.term+'学期'+' (' + #dates.format(term.startTime, 'yyyy-MM-dd') + '--' + #dates.format(term.endTime, 'yyyy-MM-dd')+') '}" th:value="${term.id}"></option>
                    </select>
                    <!--<label class="col-sm-3 control-label" style="white-space:nowrap;text-align: center">学期：</label>
                    <select name="stuterm" class="form-control m-b" th:with="type=${@dict.getType('sys_period')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>-->
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">上课周：</label>
                <div class="col-sm-8 d-flex" style="display: flex;align-items: center">
                    <input name="classlowweek" class="form-control" type="number" style="width:300px;" required>
                    <label>&nbsp;&nbsp;~&nbsp;&nbsp;</label>
                    <input name="classmaxweek" class="form-control" type="number" style="width:300px;" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">上课时间：</label>
                <div class="col-sm-8"  style="display: flex;align-items: center">
                    <select id="hid" name="courseWeektime" class="form-control m-b" th:with="type=${@dict.getType('sys_week')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>



                    <select name="firstCouretime" class="form-control m-b" th:with="type=${@classTime.selectTbClassTimeList()}">
                        <option th:each="classtime : ${type}" th:text="${classtime.section}" th:value="${classtime.id}"></option>
                    </select>
                    <select name="lastCouretime" class="form-control m-b" th:with="type=${@classTime.selectTbClassTimeList()}">
                        <option th:each="classtime : ${type}" th:text="${classtime.section}" th:value="${classtime.id}"></option>
                    </select>
                    <input name="fabuState" id="fabuState" class="form-control" value="0" type="hidden">
                    <input name="kaikeState" class="form-control" value="0" type="hidden">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上课地点：</label>
                <div class="col-sm-8">
                    <input name="courseAddress" id="courseAddress" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script type="text/javascript">
        var prefix = ctx + "website/kaikeplan"
        $("#form-plan-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-plan-add').serialize());
            }
        }
        $("input[name='courseTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        var testBsSuggest = $("#suggest-demo-1").bsSuggest({
            url: ctx + "website/totalcourse/searchSelect",
            effectiveFields: ["courseName"],
            effectiveFieldsAlias:{courseName: "课程名称"},
            showBtn: false,
            idField: "id",
            keyField: "courseName",
        }).on('onSetSelectValue', function (e, keyword) {
            console.log(keyword.id);
            $("#courseName").val(keyword.id);
        });

       var bsdskie = $('#suggest-demo-2').bsSuggest({
            url: ctx + 'website/totalcourse/searchSelect2',
            effectiveFields: ['userName'],
            effectiveFieldsAlias: {userName: '开课教师'},
            showBtn: false,
            idField: 'id',
            keyField: 'userName',
        }).on('onSetSelectValue', function (e, keyword) {
            console.log(keyword.key);
            $('#courseTeacher').val(keyword.key);
        })
    </script>
</body>
</html>